const path = require('path');
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        index: './app.js',
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'un-record.min.js'
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: '前端监控',
            template: './public/index.html',
            inject: 'head'
        }),
        new webpack.HotModuleReplacementPlugin(),    //引入热更新插件
        new webpack.BannerPlugin('@author zhuzhaofeng\n@descript 前端异常监控\nhttps://gitee.com/zhuzhaofeng/un-record.git'),
    ],
    devServer: {
        host: 'localhost',   //服务器的ip地址
        port: 8000,  //端口
        open: true,  //自动打开页面
        hot: true,   //开启热更新
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
                options: {
                    presets: ["@babel/preset-env"]
                }
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader!postcss-loader'
            }, {
                test: /\.less$/,
                loader: 'style-loader!css-loader!less-loader!postcss-loader'
            }
        ]
    }
}
